package com.taxshare.seller.controller;

import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.response.beans.Response;
import com.taxshare.seller.entity.AlsTenantInfoEntity;
import com.taxshare.seller.service.AlsTenantInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName: AlsTenantInfoController
 * @Description:
 * @author: Hai
 * @date: 2021/7/28 16:04
 */
@RestController
@RequestMapping("/alsTenantInfo")
@Api(tags = "租户信息")
public class AlsTenantInfoController {

    @Autowired
    AlsTenantInfoService alsTenantInfoService;

    @PostMapping("/queryAlsTenantInfo")
    @ApiOperation(value = "分页查询", notes = "租户信息")
    public Response queryAlsTenantInfo(@RequestBody PageRequest<AlsTenantInfoEntity> query) {
        return alsTenantInfoService.queryAlsTenantInfo(query);
    }

    @PostMapping("/addAlsTenantInfo")
    @ApiOperation(value = "新增", notes = "租户信息")
    public Response addAlsTenantInfo(@RequestBody AlsTenantInfoEntity entity) {
        return alsTenantInfoService.addAlsTenantInfo(entity);
    }

    @PostMapping("/updateAlsTenantInfo")
    @ApiOperation(value = "修改", notes = "租户信息")
    public Response updateAlsTenantInfo(@RequestBody AlsTenantInfoEntity entity) {
        return alsTenantInfoService.updateAlsTenantInfo(entity);
    }

    @GetMapping("/delAlsTenantInfo")
    @ApiOperation(value = "删除", notes = "租户信息")
    public Response delAlsTenantInfo(@RequestParam String uuid) {
        return alsTenantInfoService.delAlsTenantInfo(uuid);
    }

    @PostMapping("/queryListBySellerTaxNo")
    @ApiOperation(value = "根据销方税号查询租户信息", notes = "租户信息")
    public Response queryListBySellerTaxNo(@RequestParam String sellerTaxNo) {
        return alsTenantInfoService.queryListBySellerTaxNo(sellerTaxNo);
    }

    @PostMapping("/queryAllTenantInfo")
    @ApiOperation(value = "查询全部租户信息", notes = "租户信息")
    public Response queryAllTenantInfo() {
        return alsTenantInfoService.queryAllTenantInfo();
    }

    @GetMapping("/exportTenantInfo")
    @ApiOperation(value = "租户信息导出", notes = "租户信息")
    public void exportTenantInfo(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception{
        alsTenantInfoService.exportTenantInfo(httpServletRequest,httpServletResponse);
    }

    @PostMapping("/importGoodsManage")
    @ApiOperation(value = "租户信息导入", notes = "租户信息")
    public Response importGoodsManage(@RequestParam("file") MultipartFile multipartFile){
        return alsTenantInfoService.importTenantInfo(multipartFile);
    }

}
